package controllers;

import models.Content;
import service.ContentInterface;
import service.impl.ContentImpl;
import utils.JsonUtil;

import java.util.List;
import java.util.Map;

/**
 * 内容action
 */
public class ContentAction extends Application {

    //获取内容列表
    public static void getContentListByPage(String params) throws Exception {
        Map<String, Object> paramsMap = JsonUtil.paseJson2Map(params);
        Integer contentType = (Integer) paramsMap.get("contentType");
        String  categoryType = (String) paramsMap.get("categoryType");
        Integer pageSize = (Integer) paramsMap.get("pageSize");
        Integer pageNum = (Integer) paramsMap.get("pageNum");
        ContentInterface contentInterface = new ContentImpl();
        List<Content> list = contentInterface.getContentListByPage(contentType, categoryType, pageSize, pageNum);
        renderText(JsonUtil.parseObject(list));
    }
}
